import type { EChartsOption } from "echarts";

export async function getOption(echarts): Promise<EChartsOption> {
	let xaxisData = ["艾洪蕾", "李明涛", "赵薇", "化工", "种植业", "电商", "互联网"];
	let yaxisData = [90, 80, 100, 70, 65, 69, 80];
	return {
		backgroundColor:'#000',
		tooltip: {
			trigger: "axis",
			axisPointer: {
				type: "shadow",
			},
			backgroundColor: "rgba(255,255,255,0.75)",
			extraCssText: "box-shadow: 2px 2px 4px 0px rgba(0,0,0,0.3);",
			textStyle: {
				fontSize: 14,
				color: "#000",
			},
			formatter: (params) => {
				const item = params[0];
				return item.name + " : " + item.value + " 条";
			},
		},
		grid: {
			left: "10%",
			right: "10%",
			top: "38%",
			bottom: "28%",
			containLabel: true,
		},
		xAxis: [
			{
				type: "category",
				axisLabel: {
					interval: 0,
					color: "#fff",
					fontSize: 12,
				},
				axisLine: {
					lineStyle: {
						//y轴网格线设置
						color: "rgba(0, 168, 255, 0.4)",
						width: 1,
					},
				},
				axisTick: {
					show: false,
				},
				data: xaxisData,
			},
		],
		yAxis: [
			{
				type: "value",
				name: "",
				nameTextStyle: {
					color: "#fff",
					fontWeight: 400,
					fontSize: 14,
				},
				axisTick: {
					show: false,
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: "rgba(0, 168, 255, 0.3)",
						width: 1,
					},
				},
				splitLine: {
					show: false,
				},
				axisLabel: {
					show: true,
					fontSize: 12,
					color: "#fff",
				},
			},
		],
		series: [
			{
				type: "bar",
				barWidth: 16,
				label: {
					show: true,
					position: "top",
					color: "#00A8FF",
				},
				itemStyle: {
					borderRadius: [8, 8, 0, 0],
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
						{
							offset: 0,
							color: "#00A8FF",
						},
						{
							offset: 1,
							color: "rgba(0, 122, 255, 0)",
						},
					]),
				},
				data: yaxisData,
			},
		],
	};
}
